package com.neusoft.javafeatures9.java8stream;

import java.util.Random;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * @author yabo
 */
public class StreamExample {
    public static void main(String[] args) {
        IntStream.rangeClosed(0, 10).boxed().forEach(System.out::println);
        System.out.println("");


        System.out.println("无限生成流，这里取：前20条...");
        Stream.generate((Supplier<Object>) () -> new Random().nextLong()).limit(20).forEachOrdered(System.out::println);
        System.exit(0);
    }
}
